Skip to content

Conversation

@DianaRatnikova
Copy link

No description provided.

Copy link
Contributor

@Melevir Melevir left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Стало сильно лучше, но ещё не приехали.

С аннотациями типов надо оч много внимательности, мб из-за того что ты по вечерам/ночам сидишь – часто упускаешь какую-нибудь скобку или типа того. Просто предположение.

if __name__ == "__main__":
assert compose_full_name(first_name="John", last_name="Doe", middle_name=None) == "Doe John"
assert compose_full_name(first_name="Ilya", last_name="Lebedev", middle_name="Alexeyevich") == "Lebedev Ilya Alexeyevich"
assert compose_full_name(first_name = "John", last_name = "Doe", middle_name = None) == "Doe John"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Не, когда у функции указываешь именованые аргументы, пробелы вокруг равно не нужны. Они нужны когда равно – это присваивание значения переменной.


def is_point_in_square(point: ___, left_upper_corner: ___, right_bottom_corner: ___) -> ___:

def is_point_in_square(point: tuple[int, int], left_upper_corner: tuple[int, int], right_bottom_corner: tuple[int]) -> bool:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

right_bottom_corner тоже из двух элементов состоит :)



def get_transaction_amount(transaction_id: ___, transactions_amounts_map: ___) -> ___:
def get_transaction_amount(transaction_id:int, transactions_amounts_map: dict[int, decimal.decimal]) -> dict[int, decimal.decimal] | None:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

decimal.Decimal. Заглавную букву потеряла



def is_name_male(name: ___, name_gender_map: ___) -> ___:
def is_name_male(name: str, name_gender_map: dict[str, bool]) -> bool:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Возвращаемый тип не совсем точный



def parse_receipt(raw_receipt: ___) -> ___:
def parse_receipt(raw_receipt: str) -> tuple[int, datetime.date, list[tuple[str, int, float]]]:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

В тупле в последнем элементе не флоат

class User(TypedDict):
"name": str
"age": int
"transactions_sums": list[int]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Тут кавычки лишние, правильно как в датаклассах.

#def calculate_total_spent_for_user(user: TypedDict('User', 'name' = str, 'age' = int, 'transactions_sums' = list[int])) -> int:
#def calculate_total_spent_for_user(user: TypedDict('User', {'name': str, 'age': int, 'transactions_sums': list[int]})) -> int:

# пока на основе документации понимаю, что оба варианта верны, и именно в таком виде, без квадратных скобок
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Синтаксически это может и верно, но в реальной жизни если и приходится использвоать тайпеддикт (редко), то пригождается тот способ, которым ты воспользовалась: ты отдельно определяешь тайпдикт как класс, а потом указываешь его в аннотации.

def create_user(user_name: ___, user_age: ___, after_created: ___) -> ___:
pass

def create_user(user_name: str, user_age: int, after_created: function) -> None:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Тут пока неправильно. Посмотри, какие типы есть в модуле typing, может найдёшь чего :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants